package com.huizu.project.service.impl;

import com.huizu.project.domain.ProUser;
import com.huizu.project.mapper.ProUserMapper;
import com.huizu.project.service.RecordCardService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;

/**
 * @Author: pjl
 * @Date: 2025/3/3
 * @ClassName: RecordCardServiceImpl
 * @Description: 成绩实现类
 */
@Service
public class RecordCardServiceImpl implements RecordCardService {

    @Resource
    private ProUserMapper proUserMapper;

    @Override
    public List<ProUser> list(ProUser proUser) {
        List<ProUser> proUserList = proUserMapper.selectProUserList(proUser);
        for (ProUser user : proUserList) {
            BigDecimal jcldCj = user.getUserjcldCj().setScale(2, RoundingMode.HALF_UP);
            BigDecimal cgCj = user.getUserldcgCj().setScale(2, RoundingMode.HALF_UP);
            BigDecimal gyCj = user.getUserldgyCj().setScale(2, RoundingMode.HALF_UP);
            BigDecimal zjCj = user.getUserldzjCj().setScale(2, RoundingMode.HALF_UP);
            BigDecimal llCj = user.getUserllCj().setScale(2, RoundingMode.HALF_UP);

//            BigDecimal jcldCjZS = jcldCj.multiply(BigDecimal.valueOf(0.6)).setScale(2, RoundingMode.HALF_UP);
//            BigDecimal ldzjCjZS = zjCj.multiply((BigDecimal.valueOf(0.2))).setScale(2, RoundingMode.HALF_UP);
//            BigDecimal ldgyCjZS = gyCj.multiply((BigDecimal.valueOf(0.1))).setScale(2, RoundingMode.HALF_UP);
//            BigDecimal ldcgCjZS = cgCj.multiply((BigDecimal.valueOf(0.1))).setScale(2, RoundingMode.HALF_UP);

            BigDecimal jcld = jcldCj.multiply(BigDecimal.valueOf(0.48)).setScale(2, RoundingMode.HALF_UP);
            BigDecimal ldzj = zjCj.multiply(BigDecimal.valueOf(0.16)).setScale(2, RoundingMode.HALF_UP);
            BigDecimal ldcg = cgCj.multiply(BigDecimal.valueOf(0.08)).setScale(2, RoundingMode.HALF_UP);
            BigDecimal ldgy = gyCj.multiply(BigDecimal.valueOf(0.08)).setScale(2, RoundingMode.HALF_UP);
            BigDecimal llcj = llCj.multiply(BigDecimal.valueOf(0.20)).setScale(2, RoundingMode.HALF_UP);

            BigDecimal countPer = jcld
                    .add(ldzj)
                    .add(ldcg)
                    .add(ldgy)
                    .setScale(2, RoundingMode.HALF_UP);

            user.setUserjcldCj(jcld.stripTrailingZeros());
            user.setUserldgyCj(ldgy.stripTrailingZeros());
            user.setUserldcgCj(ldcg.stripTrailingZeros());
            user.setUserldzjCj(ldzj.stripTrailingZeros());
            user.setUsersjCj(countPer.stripTrailingZeros());
            user.setUserllCj(llcj.stripTrailingZeros());
            user.setUserAllCj(llcj.add(countPer).stripTrailingZeros());
        }
        return proUserList;
    }
}
